#include <stdio.h>
int main()
{  	  	 	
    int y, m, d, i, n;
    int sum = 0;
    printf("Input year,month,day:");
    n = scanf("%d,%d,%d", &y, &m, &d);
    if (n != 3 || y < 1990 || m < 1 || m > 12 || d > 31 || d < 1)
    {  	  	 	
        printf("Input error!\n");
        return 0;
    }
    if(m == 2)
    {  	  	 	
        if((y % 4 == 0 && y % 100 != 0)||(y%400 == 0))
        {  	  	 	
            if(d>29)
            {  	  	 	
                printf("Input error!\n");
                return 0;
            }
        }else
        {  	  	 	
            if(d > 28)
            {  	  	 	
                printf("Input error!\n");
                return 0;
            }
        }
    }
    for (i = 1990; i < y; i++)
    {  	  	 	
        if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
        {  	  	 	
            sum = sum + 366;  
        }
        else
        {  	  	 	
            sum = sum + 365; 
        }
    }
    for (i = 1; i < m; i++)
    {  	  	 	
        switch (i)
        {  	  	 	
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            sum = sum + 31;
            break;
        case 2:
            if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
            {  	  	 	
                sum = sum + 29;  
            }
            else
            {  	  	 	
                sum = sum + 28;  
            }
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            sum = sum + 30;
            break;
        }
    }
    sum = sum + d;
    sum = sum % 5;      
    if (sum == 0 || sum == 4)
    {  	  	 	
        printf("He is having a rest\n");
    }
    else
    {  	  	 	
        printf("He is working\n");
    }
    return 0;
}